feat: add arrayMethodWithBlock for block-accepting array methods#539
Merged
Conversation
Add a new C-shaped (CONDITIONAL) extension block smalrubyRuby_arrayMethodWithBlock that handles array methods accepting Ruby blocks, starting with `each`. This is a general-purpose block for block-accepting methods (not each-specific), designed to also support future methods like `tap`, `map`, `select`, etc. The block uses BlockType.CONDITIONAL (not LOOP) because not all block-accepting methods are loops (e.g., `tap` executes once). Looping behavior is controlled in the execute function via util.startBranch(1, true/false). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚀 Preview deployed: https://smalruby.jp/smalruby3-editor/feat/array-method-with-block/ |
github-actions Bot
pushed a commit
that referenced
this pull request
Apr 18, 2026
…thod-with-block feat: add arrayMethodWithBlock for block-accepting array methods
This was referenced Apr 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
smalrubyRuby_arrayMethodWithBlockを追加eachのみ実装。将来tap,map,select等を追加予定BlockType.CONDITIONALを使用(LOOP ではない —tap等の非ループメソッドにも対応するため)Block Design
eachのみ)Changes Made
VM (scratch-vm):
index.js—arrayMethodWithBlockブロック定義 + 実行メソッドblock-definitions.js—arrayMethodWithBlockMenuメニュー追加method-executors.js—executeArrayMethodWithBlock実行ロジックtranslations.json— ja/ja-Hira 翻訳追加GUI (scratch-gui):
smalruby-ruby.js(converter) —eachのコンバーター登録smalruby-ruby.js(generator) —arrayMethodWithBlockジェネレーターsmalruby-ruby.test.js— ラウンドトリップテスト追加Test Plan
Array#each with blockラウンドトリップテスト pass